//
//  YLLHTTPCient.swift
//  YLLSina
//
//  Created by 于玲玲 on 16/7/30.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit
import AFNetworking

enum YLLHTTPCientType: String {
    case GET = "GET"
    case POST = "POST"
}


class YLLHTTPCient: AFHTTPSessionManager {

    static let shareInstance: YLLHTTPCient = {
        
        let afn = YLLHTTPCient()
        
        afn.responseSerializer.acceptableContentTypes?.insert("text/plain")
        
        return afn
        
    }()
    
    func request(type: YLLHTTPCientType,URLString: String, parameters: AnyObject?, progress downloadProgress: ((NSProgress) -> Void)?, success: ((NSURLSessionDataTask, AnyObject?) -> Void)?, failure: ((NSURLSessionDataTask?, NSError) -> Void)?){
        
        if type == .GET {
            self.GET(URLString, parameters: parameters, progress: downloadProgress, success: success, failure: failure)
        }else if type == .POST{
            self.POST(URLString, parameters: parameters, progress: downloadProgress, success: success, failure: failure)
        }
        
    }
    
    

    
    
}
